// 汽车相关类型定义
export interface Car {
  id: string;
  brand: string;
  model: string;
  year: number;
  price: number;
  currency: 'USD' | 'EUR' | 'CNY';
  condition: 'new' | 'used';
  fuelType: 'gasoline' | 'diesel' | 'electric' | 'hybrid';
  transmission: 'manual' | 'automatic' | 'cvt';
  drivetrain: 'fwd' | 'rwd' | 'awd' | '4wd';
  engine: {
    displacement?: number; // 排量 (L)
    power: number; // 功率 (kW)
    torque: number; // 扭矩 (Nm)
  };
  specifications: {
    doors: number;
    seats: number;
    length: number; // mm
    width: number; // mm
    height: number; // mm
    wheelbase: number; // mm
    weight: number; // kg
    fuelConsumption?: number; // L/100km
    batteryCapacity?: number; // kWh (电动车)
    range?: number; // km (续航里程)
  };
  features: string[];
  colors: CarColor[];
  images: CarImage[];
  media?: CarMediaUpload[];
  status: 'available' | 'sold' | 'reserved' | 'offline';
  location: string;
  description: string;
  createdAt: string;
  updatedAt: string;
}

export interface CarColor {
  name: string;
  code: string;
  images: string[];
}

export interface CarImage {
  id: number;
  url: string;
  type: number;
  category: number;

}

// 媒体类型枚举
export enum MediaType {
  IMAGE = 1,
  VIDEO = 2
}

// 媒体分类枚举
export enum MediaCategory {
  EXTERIOR = 1,
  INTERIOR = 2
}

// 汽车媒体类型定义
export interface CarMedia {
  mediaId: number;
  carId: number;
  type: MediaType;
  category: MediaCategory;
  url: string;
  createTime: string;
  updateTime: string;
}

export interface CarMediaUpload {
  file: File;
  type: MediaType;
  category: MediaCategory;
  previewUrl?: string;
  uploadProgress?: number;
  isUploading?: boolean;
  error?: string;
  url?: string;
}

export interface Brand {
  id: string;
  name: string;
  slug: string;
  logo: string;
  country: string;
  founded: number;
  description: string;
  website?: string;
  carCount: number;
  isActive: boolean;
}

export interface BrandData {
  brand: string;
  name: string;
  alphabet: string;
  country: string;
  hot: string;
  desc: string;
  story: string;
}

export interface CarFilter {
  brand?: string[];
  condition?: ('new' | 'used')[];
  fuelType?: ('gasoline' | 'diesel' | 'electric' | 'hybrid')[];
  priceRange?: {
    min: number;
    max: number;
  };
  yearRange?: {
    min: number;
    max: number;
  };
  transmission?: ('manual' | 'automatic' | 'cvt')[];
  drivetrain?: ('fwd' | 'rwd' | 'awd' | '4wd')[];
  location?: string[];
  sortBy?: 'price_asc' | 'price_desc' | 'year_asc' | 'year_desc' | 'created_asc' | 'created_desc';
}

export interface SearchParams {
  q?: string;
  page?: number;
  limit?: number;
  filters?: CarFilter;
}

// 用户相关类型
export interface User {
  id: string;
  email: string;
  name: string;
  role: 'admin' | 'user';
  avatar?: string;
  createdAt: string;
}

// 公司信息类型
export interface CompanyInfo {
  name: string;
  description: string;
  address: string;
  phone: string;
  email: string;
  website: string;
  socialMedia: {
    facebook?: string;
    twitter?: string;
    instagram?: string;
    linkedin?: string;
  };
  businessHours: {
    weekdays: string;
    weekends: string;
  };
  certifications: string[];
}

// 语言类型
export type Locale = 'zh' | 'en' | 'ja' | 'ko';

export interface LocaleConfig {
  code: Locale;
  name: string;
  flag: string;
}

// API 响应类型
export interface ApiResponse<T> {
  success: boolean;
  data: T;
  message?: string;
  pagination?: {
    page: number;
    limit: number;
    total: number;
    totalPages: number;
  };
}

// 表单类型
export interface CarFormData extends Omit<Car, 'id' | 'createdAt' | 'updatedAt'> {}

export interface BrandFormData extends Omit<Brand, 'id' | 'carCount'> {}

// 统计数据类型
export interface DashboardStats {
  totalCars: number;
  newCars: number;
  usedCars: number;
  electricCars: number;
  totalBrands: number;
  recentlyAdded: Car[];
  popularBrands: Array<{
    brand: string;
    count: number;
  }>;
}